package com.hzsk.lisence.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册TestInterceptor拦截器
        registry.addInterceptor(loginInterceptor())
                //添加需要拦截的路径
                .addPathPatterns("/**")
                //添加不拦截的请求路径
                .excludePathPatterns("/api/lisence/userinfo/userlogin",
                        "/api/lisence/ukey/verify",
                        "/api/lisence/ukey/generate-password",
                        "/api/lisence/ukey/update-status",
                        "/api/lisence/plan/sync",
                        "/api/lisence/relation/sync-software",
                        "/api/lisence/relation/sync-device",
                        "/api/lisence/idc/checkstaffauthority",
                        "/api/lisence/idc/checkemukeyauthority",
                        "/api/lisence/idc/getdeviceidbycommandandidcid",
                        "/api/lisence/idc/getidcwritecommand",
                        "/api/lisence/idc/updatestatus",
                        "/api/lisence/file/getEmpowerFile",
                        "/api/lisence/file/list");
    }

    @Bean
    public LoginInterceptor loginInterceptor(){
        return new LoginInterceptor();
    }
}
